package cn.com.qtgl.sso.oidc.comp.security;

import cn.com.qtgl.apis.builtin.comp.proxy.BuiltinProxy;
import cn.com.qtgl.sso.oidc.comp.service.ProfileService;
import cn.com.qtgl.sso.oidc.comp.service.TokenCache;
import cn.com.qtgl.sso.oidc.comp.service.TokenService;
import cn.melonlib.cores.identification.comp.messenger.OrganizationManager;
import cn.melonlib.cores.identification.model.entity.Organization;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@ConditionalOnProperty(value = "security.auth.mode",havingValue = "http-authorization",matchIfMissing = false)
public class HttpAuthorizationOrganizationManager implements OrganizationManager<String> {

    @Resource
    private TokenService tokenService;

    @Resource
    private TenantFactory tenantFactory;

    @Override
    public Organization<String> getOrganization() {
        return this.tenantFactory.getTenant();
    }

    @Override
    public String getCode() {
        return tokenService.getTenant();
    }
}
